﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Common;
using Operators.CMOperators;

namespace Satates.FarmerStates
{
    public class FarmerStates : Template
    {
        private int leftWolf = 0;
        private int leftSheep = 0;
        private int leftCabbage = 0;
        private int leftFarmer = 0;
        private int rightWolf = 0;
        private int rightSheep = 0;
        private int rightCabbage = 0;
        private int rightFarmer = 0;


        public static State initalState()
        {
            return new State(new FarmerStates(0, 0, 0, 0, 1, 1, 1, 1), new InitialState());
        }

        public static List<State> finalStates()
        {
            List<State> fStates = new List<State>();
            fStates.Add(new State(new FarmerStates(1, 1, 1, 1, 0, 0, 0, 0), null));
            return fStates;
        }
        public FarmerStates(FarmerStates s)
        {
            this.leftWolf = s.leftWolf;
            this.leftSheep = s.leftSheep;
            this.leftCabbage = s.leftCabbage;
            this.leftFarmer = s.leftFarmer;
            this.rightWolf = s.rightWolf;
            this.rightSheep = s.rightSheep;
            this.rightCabbage = s.rightCabbage;
            this.rightFarmer = s.rightFarmer;
        }
        public object Clone()
        {
            return this.MemberwiseClone();
        }
        public FarmerStates(int leftWolf, int leftSheep, int leftCabbage,
                int leftFarmer, int rightWolf, int rightSheep, int rightCabbage,
                int rightFarmer)
        {
            //super();
            this.leftWolf = leftWolf;
            this.leftSheep = leftSheep;
            this.leftCabbage = leftCabbage;
            this.leftFarmer = leftFarmer;
            this.rightWolf = rightWolf;
            this.rightSheep = rightSheep;
            this.rightCabbage = rightCabbage;
            this.rightFarmer = rightFarmer;
        }

        public int getLeftWolf()
        {
            return leftWolf;
        }
        public void setLeftWolf(int leftWolf)
        {
            this.leftWolf = leftWolf;
        }
        public int getLeftSheep()
        {
            return leftSheep;
        }
        public void setLeftSheep(int leftSheep)
        {
            this.leftSheep = leftSheep;
        }
        public int getLeftCabbage()
        {
            return leftCabbage;
        }
        public void setLeftCabbage(int leftCabbage)
        {
            this.leftCabbage = leftCabbage;
        }
        public int getLeftFarmer()
        {
            return leftFarmer;
        }
        public void setLeftFarmer(int leftFarmer)
        {
            this.leftFarmer = leftFarmer;
        }
        public int getRightWolf()
        {
            return rightWolf;
        }
        public void setRightWolf(int rightWolf)
        {
            this.rightWolf = rightWolf;
        }
        public int getRightSheep()
        {
            return rightSheep;
        }
        public void setRightSheep(int rightSheep)
        {
            this.rightSheep = rightSheep;
        }
        public int getRightCabbage()
        {
            return rightCabbage;
        }
        public void setRightCabbage(int rightCabbage)
        {
            this.rightCabbage = rightCabbage;
        }
        public int getRightFarmer()
        {
            return rightFarmer;
        }
        public void setRightFarmer(int rightFarmer)
        {
            this.rightFarmer = rightFarmer;
        }
        public override string ToString()
        {
            string leftSide = "Left side: ";
            if (leftWolf == 1) leftSide += "Wolf ";
            if (leftSheep == 1) leftSide += "Sheep ";
            if (leftCabbage == 1) leftSide += "Cabbage ";
            if (leftFarmer == 1) leftSide += "Farmer ";

            string rightSide = "Right side: ";
            if (rightWolf == 1) rightSide += "Wolf ";
            if (rightSheep == 1) rightSide += "Sheep ";
            if (rightCabbage == 1) rightSide += "Cabbage ";
            if (rightFarmer == 1) rightSide += "Farmer ";
            var result = leftSide + "~~~~~ " + rightSide;
            return result;
        }
        public bool Equals(FarmerStates s)
        {
            if ((this.leftCabbage == s.leftCabbage) && (this.leftFarmer == s.leftFarmer) && (this.rightFarmer == s.rightFarmer) && (this.rightCabbage == s.rightCabbage) && (this.rightWolf == s.rightWolf) && (this.leftWolf == s.leftWolf))
                return true;
            return false;

        }
    }
}
